package com.huike.web.controller.clues;


import com.huike.clues.domain.TbClue;
import com.huike.clues.domain.TbClueTrackRecord;
import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.service.ITbClueTrackRecordService;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 线索查询跟进记录列表
 */
@RestController
@RequestMapping("/clues/record")
public class TbCluesRecordController extends BaseController {

    @Autowired(required = false)
    private ITbClueTrackRecordService iTbClueTrackRecordService;

    @RequestMapping("/list")
    public TableDataInfo list(@RequestParam("clueId") Long clueId){
        startPage();
        //在这里执行查询
        List<TbClueTrackRecord> list = iTbClueTrackRecordService.selectTbClueTrackRecord(clueId);

        return getDataTable(list);
    }

    @PostMapping
    public AjaxResult saveCluesTrackRecord(@RequestBody ClueTrackRecordVo clueTrackRecordVo){
        TbClueTrackRecord tbClueTrackRecord = new TbClueTrackRecord();
        BeanUtils.copyProperties(clueTrackRecordVo,tbClueTrackRecord);
        TbClue tbClue = new TbClue();
        BeanUtils.copyProperties(clueTrackRecordVo,tbClue);
        iTbClueTrackRecordService.saveCluesTrackRecord(tbClueTrackRecord,tbClue);
        return AjaxResult.success();
    }

}
